package com.xul.srb.core.controller.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xul.common.result.Result;
import com.xul.srb.core.pojo.entity.UserInfo;
import com.xul.srb.core.pojo.query.UserInfoQuery;
import com.xul.srb.core.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户基本信息 前端控制器
 * </p>
 *
 * @author xul
 * @since 2021-11-06
 */
@Api(tags = "后台会员管理")
@RestController
// @CrossOrigin
@RequestMapping("/admin/core/userInfo")
@Slf4j
public class AdminUserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @ApiOperation("获取积分列表")
    @GetMapping("/list/{page}/{limit}")
    public Result listPage(@ApiParam(value = "当前页面", required = true)
                           @PathVariable Long page,
                           @ApiParam(value = "每页记录数", required = true)
                           @PathVariable Long limit,
                           @ApiParam(value = "查询对象条件", required = false)
                                   UserInfoQuery userInfoQuery) {

        IPage<UserInfo> pageModel = userInfoService.listPage(page, limit, userInfoQuery);
        return Result.ok().data("pageModel", pageModel);
    }

    @ApiOperation("锁定和解锁")
    @PutMapping("/lock/{id}/{status}")
    public Result lock(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        userInfoService.lock(id, status);
        return Result.ok().message(status == 1 ? "解锁成功" : "锁定成功");
    }


}

